home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / asmsrc / tango2.lha / SOURCES / p2.s1 < prev    next >
Encoding:
Text File  |  1988-07-19  |  7.1 KB  |  341 lines

  1.  
  2.     opt c-
  3.     section blitter,code_c            Chip Ram please !!
  4.     include    df1:definitions            Give me some hardware reggies
  5.     include    df1:macros                Give me some macros
  6.     
  7.         
  8. ;LOCAL CONSTANTS
  9.  
  10. icra        equ $bfed01                
  11. allocmem     =-30-168                
  12. freemem     =-30-180                
  13. fontmemory    =4000
  14.  
  15.         
  16.  
  17. TAKEOVER:
  18.         
  19.     LEA custom,a5        
  20.     LEA GFXLIB(PC),a1             Point to 'graphics.library'
  21.     MOVEQ #0,D0                     Doesn't matter which version
  22.      MOVE.L 4.w,a6                 EXECBASE
  23.     jsr    -132(a6)                 task switching off (forbid)
  24.      JSR -$228(a6)                  Openlibrary
  25.      MOVE.L D0,GFXBASE             Store library address
  26.  
  27.         
  28. ;Now put the graphic addresses in the CopperList         
  29.  
  30.      move.l    #sin_screen,d1        Bitplane memory address
  31.      move.w    d1,bp1lo+2
  32.      swap    d1
  33.      move.w    d1,bp1hi+2
  34.  
  35.     
  36.      move.l GFXBASE,d0            Move gfxbase offset to d0
  37.      MOVE.L D0,A6                
  38.      MOVE.W #$80,dmacon(a5)        Turn off copper whilst changing it
  39.      MOVE.L $32(A6),WBCOPPER         Store old (WBench) copper address
  40.      MOVE.L #OURCOPPER,$32(A6)    Point to new copper list (our own)
  41.      MOVE.W #$8080,dmacon(a5)    re-enable copper
  42.  
  43.      MOVE.W #$8010,intena(a5)        
  44.      MOVE.L $6c,old                Save work bench interrupt
  45.      MOVE.L #LEV3,$6c            This sets up a level 3 interrupt
  46.     move.w    intenar(a5),systemints
  47.     move.b    #%01111111,icra        Kill keyboard
  48.         
  49. WAIT:     
  50.     BTST #6,$BFE001                This waits for the left
  51.      BNE.S    WAIT                mouse button to be pressed
  52.     move.l    4.w,a6                EXECBASE
  53.      MOVE.L old,$6c                Restore system interrupts
  54.     MOVE.L GFXBASE,A6
  55.      MOVE.W #$80,dmacon(a5)        Disable DMA
  56.      MOVE.L WBCOPPER,$32(A6)        Restore old copperlist
  57.      MOVE.W #$8080,dmacon(a5)    Enable DMA
  58.      move.w    systemints,d0        Systems interrupt
  59.      or.w    #$c000,d0
  60.      move.w    d0,intena(a5)        Enable OS interrupts
  61.      move.b    #%10011011,icra        Enable keyboard
  62.     clr.w    $dff0a8                Clear music
  63.     clr.w    $dff0b8
  64.     clr.w    $dff0c8
  65.     clr.w    $dff0d8
  66.     move.w    #$f,$dff096
  67.     rts
  68.  
  69.  
  70. ERROR:    
  71.     move.l 4.w,a6                Get EXECBASE
  72.     jsr    -138(a6)                Permit ( multi-tasking on )
  73.     moveq    #0,d0                Clear d0
  74.      RTS                            Return to AmigaDOS
  75.  
  76.  
  77. ;This is the NEW level 3 interrupt
  78.  
  79. LEV3:
  80.      MOVEM.L d0-d7/a0-a6,-(sp)    Save all registers to the stack
  81.     lea    custom,a5
  82.     AND #$10,intreqr(a5)           Check if interrupt is from Copper 
  83.     BNE out
  84.     move.w    #$8010,$9c                                
  85.  
  86.     bsr    try_sin
  87.     bsr    scroll
  88.     
  89.  
  90. out:     
  91.     MOVEM.L (sp)+,d0-d7/a0-a6    Restore the registers
  92.     DC.W $4ef9                    hex value for  JMP instruction
  93. old:     
  94.     DC.L 0                        will jump to normal interrupt
  95.  
  96.                                                 
  97. ; ** THE SCROLL ROUTINE **
  98.  
  99. scroll
  100.     cmp.l    #15,val                    Blitshifted all <<<
  101.     blo.s    coarse_scroll_it        No then get doing it !!
  102.     bsr        blit_char                Blit letter to screen
  103.     clr.l    val                        Reset index
  104. coarse_scroll_it:
  105.     bsr        coarse                    Scroll all line
  106.     rts                            
  107.     
  108.     
  109. ; ** BLIT LETTER ON THE SCREEN **
  110.  
  111. blit_char
  112.     jsr        text
  113.     lea        custom,a5                Get custom chip address
  114.     move.l    screenx,a0                 Can~t see this picture !!
  115.     move.l    #font,a1                 Put font in blitter source
  116.     add.l    d1,a1
  117. blit_test:
  118.     btst    #14,$dff002                 Blitter busy !!!
  119.     bne    blit_test                     Lets wait till she finishes !
  120.     move.w    #$ffff,bltafwm(a5)        Mask (DON'T NEED ONE)
  121.     move.w    #$ffff,bltalwm(a5)        Mask (DON'T NEED ONE)
  122.     move.l    a0,bltdpth(a5)             Blitter dest D (BOTTOM OF SCREEN)
  123.     move.l    a1,bltapth(a5)             Blitter source A (SCROLLING FONT)
  124.     move.w    #38,bltamod(a5)             Modulo (20-1)*2
  125.     move.w    #38,bltdmod(a5)             Modulo (20-1)*2
  126.     move.w    #$9f0,bltcon0(a5)         Minterms D=A
  127.     clr.w    bltcon1(a5)                 Set Ascending mode
  128.      move.w    #16*64+1,bltsize(a5)     Blit size (SIZE OF FONT)
  129.     rts                                  Return
  130.  
  131.  
  132. ; ** BLITSHIFT THE ENTIRE SCROLL LINE (BETTER THAN USING THE HARDWARE).
  133.  
  134. coarse:
  135.     lea        custom,a5                 
  136.     move.l    screenx,a0                ; Can~t see this picture !!
  137.     move.l    a0,a1
  138.     add.l    #2,a1
  139. blit_wait:
  140.     btst    #14,$dff002            
  141.     bne        blit_wait
  142.     incl    #4,val                    ; (1 for slower)
  143.     move    #12,d7                    ; Amount of pixels to shift(15 for slow)
  144.     ror        #4,d7                    ; Set to correct bits (12-15)
  145.     or        #%100111110000,d7        
  146.     move.l    #-1,bltafwm(a5)
  147.     move.l    a1,bltapth(a5)
  148.     move.l    a0,bltdpth(a5)
  149.     move.w    #0,bltamod(a5)
  150.     move.w    #0,bltdmod(a5)
  151.     move.w    d7,bltcon0(a5)    
  152.     move.w    #80*64+20,bltsize(a5)
  153.     rts    
  154.  
  155.  
  156. ; ** BLITTER CLEAR WHERE THE SINE SCROLL HAS JUST BEEN **
  157.  
  158. CLEAR:
  159.     Move.l    #sin_screen,a0
  160. wate
  161.     btst    #14,$dff002
  162.     bne.s    wate
  163.     Move.l    a0,Bltdpth(a5)
  164.     Move    #0,Bltdmod(a5)
  165.     Move.l    #$1f00000,Bltcon0(a5)
  166.     Move    #80*64+20,Bltsize(a5)
  167.     Rts
  168.  
  169.  
  170.  
  171. try_sin:
  172.     bsr        clear
  173.     Move.l        Table1,A3
  174.     Move.b        (A3),d1
  175.     Cmp.b        #$ff,d1
  176.     Bne            ItsOkYa
  177.     Move.l        #SinTab,A3
  178. ItsOkYa
  179.     Add.l        #$1,A3
  180.     Move.l        a3,Table1
  181.     Move.l        A3,Table
  182.     lea        custom,a5                 
  183.     move.l    screenx,a0                 ; Source A
  184.     move.l    #20,d4                    ; Number of chars along screen
  185.     clr.l    d5
  186.     clr.l    d6
  187. blit_test0:
  188.     btst    #14,$dff002                 
  189.     bne    blit_test0                     
  190.     move.l    #sin_screen,a1
  191.     bsr        get_sinvalue
  192.     move.w    #$ffff,bltafwm(a5)        
  193.     move.w    #$ffff,bltalwm(a5)        
  194.     move.l    a1,bltdpth(a5)             
  195.     move.l    a0,bltapth(a5)             
  196.     move.w    #38,bltamod(a5)             
  197.     move.w    #38,bltdmod(a5)             
  198.     move.w    #$9f0,bltcon0(a5)         
  199.     clr.w    bltcon1(a5)                 
  200.      move.w    #16*64+1,bltsize(a5)     
  201.     add.l    #2,a0                    ; Get next letter along
  202.     add.l    #2,d6
  203.     dbf        d4,blit_test0
  204.     rts                                  
  205.  
  206. get_sinvalue:
  207.     Clr.l    D5
  208.     Move.l    Table,A3
  209.     Move.b    (A3),d5
  210.     cmp.b    #$ff,d5
  211.     bne        aslam
  212.     Move.l    #SinTab,A3
  213.     Move.b    (a3),d5
  214. Aslam
  215.     Add.l    #$1,A3
  216.     Move.l    A3,Table
  217.     mulu    #40,d5
  218.     add.l    d5,a1
  219.     Add.l    D6,A1
  220.     rts
  221. Table1:    Dc.l    SinTab    
  222. table:    dc.l    sintab
  223. sintab:
  224.     dc.b $3C,$3F,$42,$46,$49,$4C,$50,$53,$56,$59
  225.     dc.b $5C,$5F,$61,$64,$67,$69,$6B,$6D,$6F,$71
  226.     dc.b $72,$73,$75,$76,$76,$77,$77,$77,$77,$77
  227.     dc.b $77,$76,$76,$75,$73,$72,$71,$6F,$6D,$6B
  228.     dc.b $69,$67,$64,$61,$5F,$5C,$59,$56,$53,$50
  229.     dc.b $4C,$49,$46,$42,$3F,$3C,$38,$35,$31,$2E
  230.     dc.b $2B,$27,$24,$21,$1E,$1B,$18,$16,$13,$10
  231.     dc.b $E,$C,$A,$8,$6,$5,$4,$2,$1,$1
  232.     dc.b $0,$0,$0,$0,$0,$0,$1,$1,$2,$4
  233.     dc.b $5,$6,$8,$A,$C,$E,$10,$13,$16,$18
  234.     dc.b $1B,$1E,$21,$24,$27,$2B,$2E,$31,$35
  235.     dc.b $38,255
  236.  Even
  237.  
  238. ; ** CHARACTER DECODER ROUTINE **
  239.  
  240. text:
  241.     move.l    acurent,a2                Get message
  242.     clr.l    d1                        
  243.     move.b    (a2)+,d1                Update it
  244.     move.b    d1,letter                Store in offset
  245.     cmp.b    #255,d1                    Check for end of message
  246.     beq.w    rst_text                If equal, then reset
  247.     sub.l    #32,d1                    Subract 32 (ie space)
  248.     asl        d1                        Times by 2 
  249.     move.l    a2,acurent                Update acurent
  250.     CMP.B    #"4",letter                Is letter "K" or larger
  251.     BPL.s    add_more                If larger then add on
  252.     rts                                Return
  253. add_more:
  254.     CMP.B    #"H",letter                Is letter "U" or larger
  255.     BPL.S    add_more2                If larger then add on
  256.     add.l    #40*15,d1                Get next line down (KLMNOPQRST)
  257.     rts
  258. add_more2:                    
  259.     add.l    #40*30,d1                Get next line down (UVWXYZ0123)
  260.     rts
  261. rst_text:
  262.     move.l    #0,d1
  263.     move.l    #message,d2                Get begining of text
  264.     move.l    d2,acurent                Reset to begining
  265.     rts                                Return
  266.  
  267.  
  268. message:
  269.  
  270. ; *=FACE    
  271.  
  272.     DC.B    "TANGO OF CRYPTIC UK PRESENTS A SMALL INTRO NO WAY NEAR"
  273.     DC.B    " FINISHED.    "
  274.     DC.B    255
  275.     EVEN
  276.             
  277.  
  278. ; ** THE COPPERLIST **
  279.  
  280. OURCOPPER:
  281.         dc.w    $120,0
  282.         dc.w    $122,0
  283.         dc.w    bpl1mod,0,bpl2mod,0
  284.         dc.w    diwstrt,$2c81+32,diwstop,$2cc1-32
  285.         dc.w    bplcon0,$1200,bplcon1,$0000
  286.         dc.w    ddfstrt,$38,ddfstop,$d0
  287.         dc.w    color00,$000,color01,$094
  288. bp1lo:    dc.w    bpl1ptl,$0000
  289. bp1hi:    dc.w    bpl1pth,$0000
  290.         end_copper
  291.         
  292.  
  293. ;LOCAL CONSTANTS
  294.  
  295. WBCOPPER:        DC.L    0
  296. GFXLIB:            DC.B     "graphics.library",0
  297. GFXBASE:        DC.L    0
  298. systemints:        dc.l    0
  299. scroll_offset:    dc.l    0
  300. screenx:        dc.l    picture
  301. letter:            dc.b    0
  302. acurent:        dc.l    message
  303. val:            dc.l    0
  304.  
  305.  
  306. ;BINARY FILES TO BE INCLUDED
  307.     EVEN
  308. picture    
  309.     dcb.b    10240,0
  310. sin_screen:
  311.     dcb.b    10240,0
  312. font
  313.     incbin    df1:neatfont.bin
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.     
  324.     
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.     
  333.     
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.